﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Utils;

public partial class forum_index : FBasePage
{
    // Fields
    public List<Maticsoft.Model.topic> bbslist = new List<Maticsoft.Model.topic>();

    public string pagenum = "1";
    public string strpage;
    public int typeid;

    // Methods
    public void Get_Bbs()
    {
        int num;
        Maticsoft.BLL.topic topic = new Maticsoft.BLL.topic();
        Maticsoft.BLL.Category category = new Maticsoft.BLL.Category();
        string ename = "";
        if (base.CurrentCity != null)
        {
            ename = base.CurrentCity.Ename;
        }
        string tabelname = "(select topic.* from topic left join category on(topic.public_id=category.id)) ttt1";
        this.bbslist = topic.Searchtopic1(30, Convert.ToInt32(this.pagenum), "*", "order by Head desc,create_time desc", "Parent_id=0", out num, tabelname);
        if (this.bbslist.Count == 0)
        {
            this.strpage = "对不起，没有相关数据";
        }
        else if (num >= 30)
        {
            this.strpage = topic.GetBBsPageStr(num, Convert.ToInt32(this.pagenum), 30);
        }
    }

    public string Get_name(string ename)
    {
        Maticsoft.BLL.Category category = new Maticsoft.BLL.Category();
        return category.Get_name(this.Session["ename"].ToString());
    }

    public string Gettype(string id)
    {
        Maticsoft.BLL.Category category = new Maticsoft.BLL.Category();
        Maticsoft.BLL.Category category2 = new Maticsoft.BLL.Category();
        if (id != "0")
        {
            if (category.GetModel(Convert.ToInt32(id)).Zone == "city")
            {
                return "本地";
            }
            return "公共";
        }
        return "";
    }

    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
        base.SetTitle("讨论区");
        if (base.Request["pgnum"] != null)
        {
            if (Utility.IsNum(base.Request["pgnum"].ToString()))
            {
                this.pagenum = base.Request["pgnum"].ToString();
            }
            else
            {
                this.SetError("您输入的参数非法");
            }
        }
        this.Get_Bbs();
    }

}